package com.zc;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.Scanner;

import com.dom4j.JE;
import com.dom4j.XF;
import com.dom4j.YM;
import com.dom4j.ZF;
import com.test.Test;

public class ZC {
	// 创建新手机号，并且不和已注册手机号重复。
	static ArrayList<String> list = new ArrayList<String>();
	private static void kh() {
		for (int j = 0; j < 9;) {
			String a = "139";
			String c = null;
			for (int i = 0; i < 8; i++) {
				int b = new Random().nextInt(10);
				c = String.valueOf(b);
				a += c;
			}
			boolean sjh = YM.bdSJH(a, YM.root);
			if (sjh) {
				j++;
				list.add(a);
			}
		}
	}

	static String str = null;
//注册界面
	public static void ZC() {
		Scanner in = new Scanner(System.in);
		list.clear();
		kh();
		for (int i = 0; i < list.size(); i++) {
			System.out.println((i + 1) + "." + list.get(i));
		}
		System.out.println("请选择卡号:");
		if (in.hasNextInt()) {
			int a = in.nextInt();
			if (a < 10 && a > 0) {
				str=list.get(a -1);
				System.out.println("请选择套餐内容");
				ZF.tcm();
				if (in.hasNextInt()) {
					int b = in.nextInt();
					in.nextLine();
					System.out.println("请输入注册用户名");
					String name = in.nextLine();
					System.out.println("请输入密码");
					String pwd = in.nextLine();
					System.out.println("请输入充值多少钱");
					String num = in.nextLine();
					long c = 0;
					try {
						c = Integer.valueOf(num);
					} catch (NumberFormatException e) {
						// TODO: handle exception
						System.out.println("请输入纯数字");
						ZC();
					}
					switch (b) {
					case 1:
						if (c < 58) {
							System.out.println("金额不足注册失败");
							ZC();
						}
						break;
					case 2:
						if (c < 68) {
							System.out.println("金额不足注册失败");
							ZC();
						}
						break;
					case 3:
						if (c < 78) {
							System.out.println("金额不足注册失败");
							ZC();
						}
						break;
					default:
						System.out.println("套餐内容选择错误");
						break;
					}
					YM.add(str, name, pwd, num, b);
					XF.add(str);
					JE.add(str);
					Test.zjm();
				}
			}

		}
		System.out.println("输入错误");
		ZC();
	
}}
